﻿#include "loginwidget.h"
#include "ui_loginwidget.h"
#include <QMessageBox>
#include "mainwindow.h"

loginwidget::loginwidget(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::loginwidget)
{
    ui->setupUi(this);
    m_pMainWindow = new MainWindow();
}

loginwidget::~loginwidget()
{
    delete ui;
    if(m_pMainWindow)
    {
        delete m_pMainWindow;
        m_pMainWindow = nullptr;
    }
}

//点击登录按钮
void loginwidget::on_loginBt_clicked()
{
    QString username = ui->userEdit->text();
    QString password = ui->passEdit->text();
    if(username == "admin" && password == "admin")
    {
        QMessageBox::information(this,QStringLiteral("提示"),QStringLiteral("登录成功！"));
        this->hide();
        m_pMainWindow->show();
    }
    else {
        QMessageBox::warning(this,QStringLiteral("提示"),QStringLiteral("用户名或者密码错误！"));
    }
}
